package com.jt.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jt.pojo.Item;
import com.jt.pojo.ItemDesc;
import com.jt.service.DubboItemService;
import com.jt.vo.EasyUITable;
import com.jt.vo.SysResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jt.service.ItemService;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ItemController {




	@Autowired
	private ItemService itemService;
	@RequestMapping("item/query")
	public EasyUITable findItemByPage(int page,int rows){

		return itemService.findItemByPagePackage(page,rows);
	}

	@RequestMapping("/item/save")
	public SysResult itemSave(Item item, ItemDesc itemDesc){
		itemService.saveItem(item,itemDesc);
		return SysResult.success();
	}

	@RequestMapping("/item/query/item/desc/{itemId}")
	public SysResult itemFind(@PathVariable Long itemId){
		return SysResult.success(itemService.findItemById(itemId));
	}

	@RequestMapping("/item/update")
	public SysResult itemUpdate(Item item){
		itemService.updateItem(item);
		return SysResult.success();
	}
//	删除多列数据
	@RequestMapping("/item/delete")
	public SysResult itemDelete(Long... ids){
		itemService.deleteItem(ids);
		return SysResult.success();
	}



	@RequestMapping("/item/{status}")
	public SysResult updateStatus(Long[] ids,@PathVariable Integer status){
		itemService.updateStatus(ids,status);
		return SysResult.success();

	}





	
	
	
}
